<template>
  <div>
    <CommonNormal
      @changeLoading="changeLoading"
      :customForm="form"
      :riverId="riverId"
      :indexName="indexName"
      :indexId="indexId"
      @setDisabled="setDisabled"
      @setBakData="setBakData"
      @refreshIndexList="refreshIndexList">
      <!-- 自定义 -->
      <template>
        <el-row>
          <el-col :span="span">
            <el-form-item :label="labels.myc + ':'" label-width="200px">
              <avue-input-number :disabled="disabled" v-model="form.myc" :min="0"></avue-input-number>
            </el-form-item>
          </el-col>
        </el-row>
      </template>
    </CommonNormal>
    <div class="submit">
      <el-button type="success" @click="checkAll" class="submit-btn">提交</el-button>
    </div>
  </div>
</template>

<script>
import { mixin } from "@/views/river/IndexComponents/mixin"
import { base } from "./base"
import CommonNormal from "@/views/river/IndexComponents/CommonNormal.vue"
import { putObj } from "@/api/river"

export default {
  mixins: [mixin, base],
  components: {
    CommonNormal,
  },
  methods: {
    checkAll() {
      let treeData = this.$store.getters.treeData
      let finished = true
      let score = 0
      for (let i in treeData) {
        if (!treeData[i].finished) {
          finished = false
          break
        }
        score += treeData[i].score
      }
      if (finished) {
        this.$confirm("确认提交?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          putObj({
            id: this.riverId,
            selfScore: score,
          }).then((res) => {
            this.$message.success("提交成功")
          })
        })
      } else {
        this.$message.warning("您有指标未填写完毕，请检查一下")
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.el-input-number--small {
  width: 100%;
}
.submit {
  display: flex;
  flex-direction: row;
  justify-content: center;

  .submit-btn {
    margin-top: 10px;
    width: 30%;
  }
}
</style>
